home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp.idb / usr / freeware / include / libgimp / gimpvector.h.z / gimpvector.h
Encoding:
C/C++ Source or Header  |  2002-07-08  |  3.9 KB  |  131 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
  3.  *
  4.  * The gimp_vector* functions were taken from:
  5.  * GCK - The General Convenience Kit
  6.  * Copyright (C) 1996 Tom Bech
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Lesser General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Lesser General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Lesser General Public
  19.  * License along with this library; if not, write to the
  20.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21.  * Boston, MA 02111-1307, USA.
  22.  */
  23.  
  24. #ifndef __GIMP_VECTOR_H__
  25. #define __GIMP_VECTOR_H__
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif /* __cplusplus */
  30.  
  31. /* For information look into the C source or the html documentation */
  32.  
  33.  
  34. typedef struct _GimpVector2 GimpVector2;
  35. typedef struct _GimpVector3 GimpVector3;
  36. typedef struct _GimpVector4 GimpVector4;
  37.  
  38. struct _GimpVector2
  39. {
  40.   gdouble x, y;
  41. };
  42.  
  43. struct _GimpVector3
  44. {
  45.   gdouble x, y, z;
  46. };
  47.  
  48. struct _GimpVector4
  49. {
  50.   gdouble x, y, z, w;
  51. };
  52.  
  53. /* Two dimensional vector functions */
  54. /* ================================ */
  55.  
  56. gdouble     gimp_vector2_inner_product (GimpVector2 *vector1,
  57.                     GimpVector2 *vector2);
  58. GimpVector2 gimp_vector2_cross_product (GimpVector2 *vector1,
  59.                     GimpVector2 *vector2);
  60. gdouble     gimp_vector2_length        (GimpVector2 *vector);
  61. void        gimp_vector2_normalize     (GimpVector2 *vector);
  62. void        gimp_vector2_mul           (GimpVector2 *vector,
  63.                     gdouble      factor);
  64. void        gimp_vector2_sub           (GimpVector2 *result,
  65.                     GimpVector2 *vector1,
  66.                     GimpVector2 *vector2);
  67. void        gimp_vector2_set           (GimpVector2 *vector,
  68.                     gdouble      x,
  69.                     gdouble      y);
  70. void        gimp_vector2_add           (GimpVector2 *result,
  71.                     GimpVector2 *vector1,
  72.                     GimpVector2 *vector2);
  73. void        gimp_vector2_neg           (GimpVector2 *vector);
  74. void        gimp_vector2_rotate        (GimpVector2 *vector,
  75.                     gdouble      alpha);
  76.  
  77. /* Three dimensional vector functions */
  78. /* ================================== */
  79.  
  80. gdouble     gimp_vector3_inner_product (GimpVector3 *vector1,
  81.                     GimpVector3 *vector2);
  82. GimpVector3 gimp_vector3_cross_product (GimpVector3 *vector1,
  83.                     GimpVector3 *vector2);
  84. gdouble     gimp_vector3_length        (GimpVector3 *vector);
  85. void        gimp_vector3_normalize     (GimpVector3 *vector);
  86. void        gimp_vector3_mul           (GimpVector3 *vector,
  87.                     gdouble      factor);
  88. void        gimp_vector3_sub           (GimpVector3 *result,
  89.                     GimpVector3 *vector1,
  90.                     GimpVector3 *vector2);
  91. void        gimp_vector3_set           (GimpVector3 *vector,
  92.                     gdouble      x,
  93.                     gdouble      y,
  94.                     gdouble      z);
  95. void        gimp_vector3_add           (GimpVector3 *result,
  96.                     GimpVector3 *vector1,
  97.                     GimpVector3 *vector2);
  98. void        gimp_vector3_neg           (GimpVector3 *vector);
  99. void        gimp_vector3_rotate        (GimpVector3 *vector,
  100.                     gdouble      alpha,
  101.                     gdouble      beta,
  102.                     gdouble      gamma);
  103.  
  104. /* 2d <-> 3d Vector projection functions */
  105. /* ===================================== */
  106.  
  107. void        gimp_vector_2d_to_3d       (gint         sx,
  108.                     gint         sy,
  109.                     gint         w,
  110.                     gint         h,
  111.                     gint         x,
  112.                     gint         y,
  113.                     GimpVector3 *vp,
  114.                     GimpVector3 *p);
  115.  
  116. void        gimp_vector_3d_to_2d       (gint         sx,
  117.                     gint         sy,
  118.                     gint         w,
  119.                     gint         h,
  120.                     gdouble     *x,
  121.                     gdouble     *y,
  122.                     GimpVector3 *vp,
  123.                     GimpVector3 *p);
  124.  
  125.  
  126. #ifdef __cplusplus
  127. }
  128. #endif /* __cplusplus */
  129.  
  130. #endif  /* __GIMP_VECTOR_H__ */
  131.